home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / windows / wdj1096.zip / TOMLINSN.ZIP / FIGURE1.C next >
Text File  |  1996-07-17  |  915b  |  49 lines

  1. // figure 1
  2.  
  3. while( TRUE  )
  4. {
  5.  
  6.    // check if we have NT, Win95 has no Services
  7.    dwVersion = GetVersion();
  8.    if( dwVersion >= 0x80000000 )
  9.    {
  10.       break ;
  11.    }
  12.  
  13.    // Try to find the service inside SCManager
  14.    schSCManager = OpenSCManager(
  15.                         NULL,
  16.                         NULL,
  17.                         SC_MANAGER_ALL_ACCESS
  18.                         );
  19.  
  20.    if( schSCManager == NULL )
  21.    {
  22.       break ;
  23.    }
  24.  
  25.    // Try to open the Service
  26.    schService = OpenService( schSCManager,
  27.                              SERVICE_SHORT_NAME,
  28.                              SERVICE_ALL_ACCESS);
  29.  
  30.    if( schService == NULL )
  31.    {
  32.       break ;
  33.    }
  34.  
  35.    // Try to Alloc a Console (Call fails if we have a Console)
  36.    if( NOT AllocConsole() )
  37.       break ;
  38.    }
  39.  
  40.    // Free Console
  41.    FreeConsole() ;
  42.  
  43.    // We are a service
  44.    lRet = TRUE ;
  45.    break ;
  46.  
  47. }
  48.  
  49.